package com.cryann.mqttserver.mqttProcess;

import com.cryann.mqttserver.service.MqttSubject;
import com.cryann.mqttserver.service.MsgStoreService;
import io.netty.channel.Channel;
import io.netty.handler.codec.mqtt.MqttMessageType;
import io.netty.handler.codec.mqtt.MqttPubAckMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author cRyann
 * @date 2018/12/21 0021 15:40
 * @description:
 */
@Component
@Slf4j
@ProcessType(MqttMessageType.PUBACK)
public class Puback implements BasicProcess<MqttPubAckMessage> {
    @Autowired
    MqttSubject mqttSubject;
    @Autowired
    MsgStoreService msgStoreService;

    @Override
    public void process(Channel ctx, MqttPubAckMessage msg) {
        switch (msg.fixedHeader().qosLevel()) {
            // 只会等于1
            case AT_LEAST_ONCE:
                break;
            case AT_MOST_ONCE:
                msgStoreService.pollMsg(ctx);
                break;
            case EXACTLY_ONCE:
                break;
            default:
                break;
        }
    }
}
